<?php

ob_start();
session_start();
include '../connect.php';

$pd_code = $_POST['pd_code'];
$pd_codeAdinop = $_POST['pd_codeAdinop'];
$pd_stWarunty = $_POST['pd_stWarunty'];
$pd_enWarunty = $_POST['pd_enWarunty'];
$pd_remark = $_POST['pd_remark'];
$pd_id = $_POST['pd_id'];
$pd_status = $_POST['pd_status'];
$pd_name = $_POST['pd_name'];


if ($pd_stWarunty != '0000-00-00') {
    $fmtStwa = date('Y-m-d', strtotime($pd_stWarunty));
    $fmtEnwa = date('Y-m-d', strtotime($pd_enWarunty));
} else {
    $fmtStwa = date("Y-m-d ", time());
    $fmtEnwa = date("Y-m-d ", time());
}



if (!empty($pd_id)) {

//    if ($pd_status != 'IsUse') {
//        $exeComp = "SELECT * FROM computer WHERE c_monitor = '$pd_code'";
//        $rsExeCom = mysql_query($exeComp);
//        $rsCn_id = mysql_fetch_array($rsExeCom);
//        $CN_ID = $rsCn_id['cn_id'];
//
//        $upComputer = "UPDATE computer SET c_monitor = '-' WHERE cn_id = '$CN_ID'";
//        mysql_query($upComputer);
//    }

    $upDateProDe = "UPDATE product_detail SET pd_codeAdinop = '$pd_codeAdinop', 
            pd_name = '$pd_name',
            pd_status = '$pd_status',
            pd_stWarunty = '$fmtStwa',
            pd_enWarunty = '$fmtEnwa',
            pd_remark = '$pd_remark'
            WHERE pd_id = '$pd_id'";

    mysql_query($upDateProDe);

    echo "<script language='javascript'>
			   alert('Complete');
    setTimeout(\"parent.$.fancybox.close()\",1000); 
			  </script>";
    echo "<meta http-equiv='refresh' content='5; url=listCom.php'>";
} else {
    echo mysql_errno();
}
?>
